package com.junjiao.util.struts2Tag;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.jsp.JspWriter;

import org.apache.struts2.components.Component;
import org.apache.struts2.views.jsp.ComponentTagSupport;

import com.opensymphony.xwork2.util.ValueStack;

public class PageTag extends ComponentTagSupport {

	private String uri;// 分页要执行的action路径
	private Integer curpage;// 当前页
	private Integer pagesize;// 每页显示的记录数
	private Integer pagecount;// 总页数
	private Integer rowcount;// 总记录数

	public Integer getCurpage() {
		return curpage;
	}

	public void setCurpage(Integer curpage) {
		this.curpage = curpage;
	}

	public Integer getPagesize() {
		return pagesize;
	}

	public void setPagesize(Integer pagesize) {
		this.pagesize = pagesize;
	}

	public Integer getPagecount() {
		return pagecount;
	}

	public void setPagecount(Integer pagecount) {
		this.pagecount = pagecount;
	}

	public Integer getRowcount() {
		return rowcount;
	}

	public void setRowcount(Integer rowcount) {
		this.rowcount = rowcount;
	}

	public String getUri() {
		return uri;
	}

	public void setUri(String uri) {
		this.uri = uri;
	}

	public Component getBean(ValueStack arg0, HttpServletRequest arg1,
			HttpServletResponse arg2) {
		// //获得页面的输出流
		// JspWriter out = this.getJspContext().getOut();
		//		    
		//		    
		// //通过流往页面写数据
		// out.println("<div class=/"pager/">");
		// out.println("共" +rowcount+ "行记录,每页");
		// out.println("<input value=/""+ pagesize + "/" size=/"2/" />条");
		// out.println("当前第<input value=/"" + (curpage +1 )+"/" size=/"2/"/>页/共"+
		// pagecount + "页");
		// out.println("<a href="/" mce_href="/""" + uri+"&curpage=0/">第一页</a>");
		//		   
		// if(curpage > 0) {
		// out.println("<a href="/" mce_href="/""" + uri+"&curpage="+(curpage-1)+"/">上一页</a>");
		// }
		// if(curpage < pagecount -1) {
		// out.println("<a href="/" mce_href="/""" + uri+"&curpage=" + (curpage+1)+"/">下一页</a>");
		// }
		// out.println("<a href="/" mce_href="/""" + uri+"&curpage=" +(pagecount-1)+"/">最后一页</a>");
		// out.println("</div>");
		return null;
	}

}
